#!/bin/bash
WOEK_NOW=$(dirname $(readlink -f "$0"))"/"

echo 7 4 1 7 > /proc/sys/kernel/printk
# disable rtc clk_out pins default
#echo 0 > /sys/class/rtc/rtc0/device/clk_out_ctl

# if test function in sd card then exec
# if [ -f "/media/mmcblk0p1/function/functiontest.sh" ]; then
# 	echo "Start functiontest.sh"
# 	cd /media/mmcblk0p1/function
# 	./functiontest.sh &
# fi


start() {
    # ip
    udhcpc -b &
    # dns
    echo 'nameserver 8.8.8.8'　>  /etc/resolv.conf
    # Set system time from hardware clock 
    # ntpdate -u ntp.api.bz &&  hwclock -w
    hwclock -s
    # test ppp
    # pppd call myppp&
}


# 硬件电源相关
$WOEK_NOW/other/eth_pw      $1 
$WOEK_NOW/other/gprs_pw     $1 


case "$1" in
  start)
	start
	;;
  stop)
	:
	;;
  restart|reload)
    : 
	;;
  *)
	echo "Usage: $0 {start|stop|restart}"
	exit 1
esac

# 调试相关,后续需要关闭的
$WOEK_NOW/other/dbg_mount   $1 
$WOEK_NOW/other/dbg_push    $1
$WOEK_NOW/other/dbg_npc     $1  & #本条一定要后台运行

if [ -f /RUN_TEST/start.sh ]; then
    /RUN_TEST/start.sh
fi

exit $?